package com.research.web.utils;

import com.alibaba.druid.pool.DruidPooledConnection;
import org.springframework.util.ObjectUtils;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class DruidUtils {
    /*** 关闭数据库连接 ****/
    public static void closeConnection(DruidPooledConnection connection, PreparedStatement preparedStatement, ResultSet resultSet) throws Exception {
        if (!ObjectUtils.isEmpty(resultSet)) {
            resultSet.close();
        }
        if (!ObjectUtils.isEmpty(preparedStatement)) {
            preparedStatement.close();
        }
        if (!ObjectUtils.isEmpty(connection)) {
            connection.close();
        }
    }
}
